package ThreadDemo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 故我
 * Date: 2023-09-17
 * Time: 13:35
 */
public class ThreadDemo7 {
    private static boolean flag = true;
    public static void main(String[] args) throws InterruptedException {

        Thread t = new Thread(()->{
            while(flag){
                System.out.println("Hello New Thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        t.start();
        Thread.sleep(3000);
        flag = false;
    }
}
